import { ObjCreate } from "../../common/ObjCreate";
import { OpenSeverSp } from "./OpenSeverSp";
import { GScrollPane } from "../../../../../com/mui/controls/GScrollPane";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { ImagesConst } from "../../../resource/ImagesConst";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { OpenSeverNewRewardBody } from "../reward/OpenSeverNewRewardBody";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { ESpecialConditonType } from "../../../../../Message/Public/ESpecialConditonType";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { EItemUpdateOper } from "../../../../../Message/Game/EItemUpdateOper";
import { DailyRule } from "../../../rules/DailyRule";
import { GameManager } from "../../../manager/GameManager";
import { ModuleType } from "../../common/ModuleType";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { DailySpecialInfo } from "../../../model/DailySpecialInfo";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { CallLater } from "../../../../common/net/CallLater";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class OpenServerDetailPanel
    
    export  class OpenServerDetailPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initView();
            return;
        }

        /* internal  */initView(): void
        {
            ObjCreate.createBg(0, 0, 489, 400, this);
            this._sp = new OpenSeverSp();
            addChild(this._sp);
            this._stStarBm = ObjCreate.createBitmap("", 2, 4, this._sp);
            this._stListBm = ObjCreate.createBitmap("", 2, 35, this._sp);
            this._timeTxt = ObjCreate.createTextField("", 48, 5, 430, 25, this._sp);
            this._infoTxt = ObjCreate.createTextField("", 6, 32, 470, 20, this._sp);
            this._infoTxt.wordWrap = true;
            this._infoTxt.multiline = true;
            this._infoTxt.autoSize = flash.text.TextFormatAlign.LEFT;
            this._scrollPane = new GScrollPane();
            this._scrollPane.width = 486;
            this._scrollPane.height = 395;
            this._scrollPane.styleName = "GScrollPane";
            this._scrollPane.verticalScrollPolicy = ScrollPolicy.AUTO;
            this._scrollPane.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._scrollPane.scrollDrag = false;
            this._scrollPane.focusEnabled = false;
            ObjCreate.createBg(45, 26, 302, 1, this._sp, ImagesConst.SplitLine);
            LoaderHelp.addResCallBack(ResFileConst.OpenServer, this.onLoadBmResource);
            this._autoBtn = ObjCreate.createGButton("", 382, 40, 78, 26, this._sp, "ButtonRedMini");
            this._autoBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onAutoBtnClickHandler);
            this._autoBtn.visible = false;
            this._rewardBody = new OpenSeverNewRewardBody();
            this._rewardBody.direction = GBoxDirection.VERTICAL;
            this._rewardBody.verticalGap = 0;
            this._rewardBody.y = 100;
            this._sp.addChild(this._rewardBody);
            this._scrollPane.source = this._sp;
            this._scrollPane.invalidate();
            this._scrollPane.drawNow();
            addChild(this._scrollPane);
            return;
        }

        protected onAutoBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=this._actInfo.conditionType;
            switch (loc1) 
            {
                case ESpecialConditonType._ESpecialConditionTypeRootTargetShow: case ESpecialConditonType._ESpecialConditonTypeAcupointLevelAndNum:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PlayerRootUpdateOpen));
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeEquipRefreshAttrAndStarNum:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast, EItemUpdateOper._EItemUpdateOperRecast));
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeRechargeReturnYB:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GotoPay));
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeRechargeReturnGift:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.DailyGiftOpen, DailyRule.GiftGet));
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypePlayerVIPType:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ShowVIPWindow));
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeEquipPerfectStrengLvAndNum:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast, EItemUpdateOper._EItemUpdateOperStrengthen));
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeEmbedJewelLevelAndNum:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast, EItemUpdateOper._EItemUpdateOperEmbedJewel));
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeRoleSuitEx:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.TreasureModuleOpen));
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypePetGrowthValue:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetOpenWindow, 2));
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypePetSpiritValue:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetOpenWindow, 1));
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeTopListBase:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.RankSelectedAssignType, {"oneIdx": 0, "twoIdx": 0}));
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypePlayerLevel: case ESpecialConditonType._ESpecialConditonTypePlayerFight: case ESpecialConditonType._ESpecialConditonTypeRoleEquipColorAndNumEx:
                {
                    GameManager.instance.popupWindow(ModuleType.Players);
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeRechargeReturn:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GotoPay));
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._stStarBm.bitmapData = GlobalClass.getBitmapData(ImagesConst.OpenServerStar);
            this._stListBm.bitmapData = GlobalClass.getBitmapData(ImagesConst.OpenServerList);
            this.resize();
            return;
        }

        public updateData(arg1: DailySpecialInfo): void
        {
            var loc1=0;
            this._actInfo = arg1;
            this.setAutoBtn(this._actInfo.conditionType);
            this._timeTxt.htmlText = HTMLUtil.addColor(Language.getString(20947) + "：", "#ffff00") + HTMLUtil.addColor(this._actInfo.activeTime, "#00ff00");
            this._infoTxt.htmlText = HTMLUtil.addColor(this._actInfo.context, GlobalStyle.color1);
            this._rewardBody.disposeChild();
            var loc2=this._actInfo.rewardDataList.length;
            while (loc1 < loc2) 
            {
                this._rewardBody.addItem(this._actInfo, loc1);
                ++loc1;
            }
            this._sp.addChild(this._rewardBody);
            this._rewardBody.goInvalidate();
            CallLater.addCallBack(this.resize);
            return;
        }

        /* internal  */setAutoBtn(arg1: int): void
        {
            var loc1=arg1;
            switch (loc1) 
            {
                case ESpecialConditonType._ESpecialConditionTypeRootTargetShow: case ESpecialConditonType._ESpecialConditonTypeAcupointLevelAndNum:
                {
                    this._autoBtn.label = Language.getString(70922);
                    this._autoBtn.visible = true;
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeEquipRefreshAttrAndStarNum:
                {
                    this._autoBtn.label = Language.getString(61002);
                    this._autoBtn.visible = true;
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeRechargeReturnYB:
                {
                    this._autoBtn.label = Language.getString(53005);
                    this._autoBtn.visible = true;
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeRechargeReturnGift:
                {
                    this._autoBtn.label = Language.getString(180108);
                    this._autoBtn.visible = true;
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypePlayerVIPType:
                {
                    this._autoBtn.label = Language.getString(41235);
                    this._autoBtn.visible = true;
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeEquipPerfectStrengLvAndNum:
                {
                    this._autoBtn.label = Language.getString(61001);
                    this._autoBtn.visible = true;
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeEmbedJewelLevelAndNum:
                {
                    this._autoBtn.label = Language.getString(61018);
                    this._autoBtn.visible = true;
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeRoleSuitEx:
                {
                    this._autoBtn.label = Language.getString(35000);
                    this._autoBtn.visible = true;
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypePetGrowthValue:
                {
                    this._autoBtn.label = Language.getString(90056);
                    this._autoBtn.visible = true;
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypePetSpiritValue:
                {
                    this._autoBtn.label = Language.getString(90057);
                    this._autoBtn.visible = true;
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeTopListBase:
                {
                    this._autoBtn.label = Language.getString(41664);
                    this._autoBtn.visible = true;
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypePlayerLevel: case ESpecialConditonType._ESpecialConditonTypePlayerFight: case ESpecialConditonType._ESpecialConditonTypeRoleEquipColorAndNumEx:
                {
                    this._autoBtn.label = Language.getString(30003);
                    this._autoBtn.visible = true;
                    break;
                }
                case ESpecialConditonType._ESpecialConditonTypeRechargeReturn:
                {
                    this._autoBtn.label = Language.getString(20565);
                    this._autoBtn.visible = true;
                    break;
                }
                default:
                {
                    this._autoBtn.visible = false;
                    break;
                }
            }
            return;
        }

        public dispose(arg1: Boolean=true): void
        {
            this._timeTxt.text = "";
            this._infoTxt.text = "";
            this._rewardBody.disposeChild();
            return;
        }

        public /* override */ get height(): number
        {
            return 128;
        }

        public resize(): void
        {
            this._stListBm.y = this._infoTxt.y + this._infoTxt.height + 8;
            this._autoBtn.y = this._infoTxt.y + this._infoTxt.height + 18;
            this._rewardBody.y = this._stListBm.y + this._stListBm.height + 3;
            this._sp.height = this._rewardBody.y + this._rewardBody.height + 5;
            this._scrollPane.refreshPane();
            this._scrollPane.update();
            return;
        }

        public onGetRewardRes(arg1: int, arg2: int): void
        {
            this._rewardBody.onGetRewardRes(arg1, arg2);
            return;
        }

        public onActiveConditionUpdate(arg1: Array<any>): void
        {
            this._rewardBody.onActiveConditionUpdate(arg1);
            return;
        }

        public updataGetRewardState(arg1: Array<any>): void
        {
            this._rewardBody.updataGetRewardState(arg1);
            return;
        }

        /* internal */ /* var */_timeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_infoTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_stStarBm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_stListBm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_scrollPane: GScrollPane;

        /* internal */ /* var */_sp: OpenSeverSp;

        /* internal */ /* var */_autoBtn: GButton;

        /* internal */ /* var */_rewardBody: OpenSeverNewRewardBody;

        /* internal */ /* var */_actInfo: DailySpecialInfo;
    }
